var Model = {
        _URL_P: Common.pa._URL_PREFIX,
        _RESULT: "",
        // 开发环境用模块
        test: {
            /**
             * userid直接登录
             */
            login: function () {
                $.ajax({
                    url: Model._URL_P + "/user/login",
                    type: "get",
                    data: {
                        "user.nickname": "3333",
                        "user.passwd": "3333"
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                        if (result.code) {
                            sessionStorage.setItem("xt_userid", result.loginedUser.userid);
                            sessionStorage.setItem("xt_photo", result.loginedUser.photo);
                        }
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
        },
        /**
         * 用户模块
         *
         */

        /*
        管理员模块
         */
        admin: {

//管理员登录
            login: function (p) {
                var params = {
                    username: "",
                    password: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/admin/login",
                    type: "get",
                    data: {
                        "admin.username": params.username,
                        "admin.password": params.password
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                        if (result.code) {
                            sessionStorage.setItem("xt_adminId", result.loginedAdmin.id);
                        }
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },

            /*

            查询所有用户信息
             */
            findAllUser: function (p) {
                $.ajax({
                    url: Model._URL_P + "/admin/findAllUser",
                    type: "get",
                    data: {},
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;

            }
        },


        user: {
            /**
             * 授权登录
             */
            login: function (p) {
                var params = {
                    nickname: "",
                    passwd: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/user/login",
                    type: "get",
                    data: {
                        "user.nickname": params.nickname,
                        "user.passwd": params.passwd
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                        if (result.code) {
                            sessionStorage.setItem("xt_userid", result.loginedUser.userid);
                            sessionStorage.setItem("xt_photo", result.loginedUser.photo);
                            // sessionStorage.setItem("xt_token", result.data.token);
                            // sessionStorage.setItem("xt_auth", result.data.auth);
                            // sessionStorage.setItem("xt_message", result.data.message);
                        }
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },

            /**
             * 用户注册
             */
            register: function (p) {
                var params = {
                    nickname: "",
                    passwd: "",
                    school: ""

                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/user/register",
                    type: "post",
                    data: {
                        "user.nickname": params.nickname,
                        "user.passwd": params.passwd,
                        "user.school": params.school
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                        // if (result.code) {
                        //     sessionStorage.setItem("xt_userid", result.loginedUser.userid);
                        //     // sessionStorage.setItem("xt_token", result.data.token);
                        //     // sessionStorage.setItem("xt_auth", result.data.auth);
                        //     // sessionStorage.setItem("xt_message", result.data.message);
                        // }
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },

            /**
             * 用户名验证
             */
            validateNickname: function (p) {
                var params = {
                    nickname: "",

                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/user/validateNickname",
                    type: "post",
                    data: {
                        "user.nickname": params.nickname,
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                        // if (result.code) {
                        //     sessionStorage.setItem("xt_userid", result.loginedUser.userid);
                        //     // sessionStorage.setItem("xt_token", result.data.token);
                        //     // sessionStorage.setItem("xt_auth", result.data.auth);
                        //     // sessionStorage.setItem("xt_message", result.data.message);
                        // }
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },

            /**
             * 我的信息
             */
            getUserInfo: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid")
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/user/findUserByUserid",
                    type: "get",
                    data: {
                        userid: params.userid
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /*
            更新用户信息
             */
            updateUserInfo: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    nickname: '',
                    passwd: '',
                    school: ''
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/user/modifyUserBaseInfo",
                    type: "post",
                    data: {
                        "user.userid": params.userid,
                        "user.nickname": params.nickname,
                        "user.passwd": params.passwd,
                        "user.school": params.school
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 我的关注/粉丝
             */
            getMyAttention: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/attention/findAllMyAttentionForPage",
                    type: "get",
                    data: {
                        "user.userid": params.userid,
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },

            /**
             * 我的关注/粉丝
             */
            getMyFans: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/attention/findAllOfMyAttentionForPage",
                    type: "get",
                    data: {
                        "user.userid": params.userid,
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 余额
             */
            getBalance: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    index: 0,
                    size: 5
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/user/GetBalance/v1",
                    type: "get",
                    data: {
                        userid: params.userid,
                        index: params.index,
                        size: params.size
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /*

            查询报表
             */
            findBillByUseridForPage: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/user/findBillByUseridForPage",
                    type: "post",
                    data: {
                        "user.userid": params.userid,
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },

            /*
            查询用户信息
             */
            findUserByUserid: function (p) {
                var params = {
                    userid: '',
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/user/findUserByUserid",
                    type: "post",
                    data: {
                        userid: params.userid,
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 充值
             */
            recharge: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    price: '',
                    state: ''
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/user/modifyBalance",
                    type: "post",
                    data: {
                        "user.userid": params.userid,
                        "bill.price": params.price,
                        "bill.state": params.state
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 提现
             */
            encash: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    account: "",
                    accountName: "",
                    accountBank: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/user/Encash/v1?userid=" + params.userid + '&account=' + params.account + '&accountName=' + params.accountName + '&accountBank=' + params.accountBank,
                    type: "post",
                    data: {
                        userid: params.userid,
                        account: params.account,
                        accountName: params.accountName,
                        accountBank: params.accountBank
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 我的地址
             */
            myAddress: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid")
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/user/MyAddress/v1",
                    type: "get",
                    data: {
                        userid: params.userid
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },

            addAddress: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    receiver: "",
                    phone: "",
                    area: "",
                    address: "",
                    postalcode: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/user/addAddress",
                    type: "post",
                    data: {
                        "user.userid": params.userid,
                        "address.receiver": params.receiver,
                        "address.phone": params.phone,
                        "address.area": params.area,
                        "address. address": params.address,
                        "address.postalcode": params.postalcode
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 修改地址
             */
            modelifyAddress: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    receiver: "",
                    phone: "",
                    area: "",
                    address: "",
                    postalcode: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/user/updateAddress",
                    type: "post",
                    data: {
                        "user.userid": params.userid,
                        "address.receiver": params.receiver,
                        "address.phone": params.phone,
                        "address.area": params.area,
                        "address. address": params.address,
                        "address.postalcode": params.postalcode
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 我的拍品
             */
            myGoods: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    index: 0,
                    size: 5
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/user/MyGoods/v1",
                    type: "get",
                    data: {
                        userid: params.userid,
                        index: params.index,
                        size: params.size
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 删除商品
             */
            delGoods: function (p) {
                var params = {
                    goodsId: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/goods/removeGoodsItem",
                    type: "post",
                    data: {
                        "goodsItem.id": params.goodsId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 拍品下架
             */
            putOffGoods: function (p) {
                var params = {
                    goodsId: "",
                    state: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/user/PutOffGoods/v1?userid=" + params.userid + '&goodsId=' + params.goodsId + '&type=' + params.type,
                    type: "post",
                    data: {
                        goodsId: params.goodsId,
                        type: params.type
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 我代理的商品
             */
            buyerProxyGoods: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    proxy: 2,
                    index: '',
                    size: ''
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/goods/findGoodsItemByProxyUseridForPage",
                    type: "get",
                    data: {
                        "user.userid": params.userid,
                        proxy: params.proxy,
                        index: params.index,
                        size: params.size
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 取消代理
             */
            cancelProxy: function (p) {
                var params = {
                    goodsId: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/goods/removeProxy",
                    type: "post",
                    data: {
                        "goodsItem.id": params.goodsId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 卖家产品库
             */
            salerProxyGoods: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    index: 0,
                    size: 5
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/user/SalerProxyGoods/v1",
                    type: "get",
                    data: {
                        userid: params.userid,
                        index: params.index,
                        size: params.size
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 下架代理拍品
             */
            putOffProxyGoods: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    goodsId: "",
                    type: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/user/PutOffProxyGoods/v1?userid=" + params.userid + '&goodsId=' + params.goodsId + '&type=' + params.type,
                    type: "post",
                    data: {
                        userid: params.userid,
                        goodsId: params.goodsId,
                        type: params.type
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 提交/修改认证
             */
            inputAuth: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    name: "",
                    phone: "",
                    service: "",
                    company: "",
                    license: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/user/InputAuth/v1?userid=" + params.userid + '&name=' + params.name + '&phone=' + params.phone + '&service=' + params.service + '&company=' + params.company + '&license=' + params.license,
                    type: "post",
                    data: {
                        userid: params.userid,
                        name: params.name,
                        phone: params.phone,
                        service: params.service,
                        company: params.company,
                        license: params.license
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 查看认证信息
             */
            authInfo: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid")
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/user/AuthInfo/v1",
                    type: "get",
                    data: {
                        userid: params.userid
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 缴纳保证金
             */
            payForBond: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    bond: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/user/PayForBond/v1?userid=" + params.userid + '&bond=' + params.bond,
                    type: "post",
                    data: {
                        userid: params.userid,
                        bond: params.bond
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 保证金提现
             */
            bondEncash: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid")
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/user/BondEncash/v1?userid=" + params.userid,
                    type: "post",
                    data: {
                        userid: params.userid
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 报表
             */
            reportForms: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid")
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/user/ReportForms/v1",
                    type: "get",
                    data: {
                        userid: params.userid
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 分享
             */
            share: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    goodsId: ''
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/goods/Share/v1?userid=" + params.userid + '&goodsId=' + params.goodsId,
                    type: "post",
                    data: {
                        userid: params.userid,
                        goodsId: params.goodsId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
        },
        /**
         * 商品模块
         */
        goods: {
            /**
             * 获取所有商品
             */
            findAllGoodsItem: function (p) {
                var params = {
                    pageSize: 0,
                    page: 5
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/goods/findAllGoodsItem",
                    type: "get",
                    data: {
                        pageSize: params.pageSize,
                        page: params.page
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 买家获取商品详情
             */
            findGoodsItemById: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    id: "",
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/goods/findGoodsItemById",
                    type: "get",
                    data: {
                        userid: params.userid,
                        "goodsItem.id": params.id,
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 搜索商品
             */
            findLikeGoodsItem: function (p) {
                var params = {
                    pageSize: 0,
                    page: 5,
                    content: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/goods/findLikeGoodsItem",
                    type: "post",
                    data: {
                        pageSize: params.pageSize,
                        page: params.page,
                        "goodsItem.content": params.content
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 点赞收藏
             */
            collectGoods: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    goodsid: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/collection/addNewCollection",
                    type: "post",
                    data: {
                        "collection.userid": params.userid,
                        "collection.goodsid": params.goodsid
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 分类商品
             */
            getClassGoods: function (p) {
                var params = {
                    cid: "",
                    index: '',
                    size: ''
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/goods/findAllGoodsItemByL_class",
                    type: "get",
                    data: {
                        "goodsItem.l_class": params.cid,
                        page: params.index,
                        pageSize: params.size
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 店铺详情
             */
            findGoodsItemByUseridForPage: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    pageSize: 0,
                    page: 5,
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/goods/findGoodsItemByUseridForPage",
                    type: "get",
                    data: {
                        pageSize: params.pageSize,
                        page: params.page,
                        "goodsItem.userid": params.userid,
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 我的收藏
             */
            collectionGoods: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    pageSize: 0,
                    page: 5
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/collection/findAllMyCollection",
                    type: "get",
                    data: {
                        "user.userid": params.userid,
                        pageSize: params.pageSize,
                        page: params.page
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 删除收藏
             */
            deleteCollection: function (p) {
                var params = {
                    id: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/collection/removeCollection",
                    type: "post",
                    data: {
                        "user.userid": sessionStorage.getItem("xt_userid"),
                        "goodsItem.id": params.id
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },


            /*

            获得可代理商品
             */
            getProxyItem: function (p) {
                var params = {
                    pageSize: '',
                    page: '',
                    proxy: 1
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/goods/findGoodsItemByProxyUseridForPage",
                    type: "post",
                    data: {
                        pageSize: params.pageSize,
                        page: params.page,
                        proxy: params.proxy
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;

            }
            ,


            /*
            添加代理
             */
            setProxyItem: function (p) {
                var params = {
                    userid: '',
                    id: ''
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/goods/addNewProxy",
                    type: "post",
                    data: {
                        "user.userid": sessionStorage.getItem("xt_userid"),
                        "goodsItem.id": params.id,
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            /**
             * 分享
             */
            getShareInfo: function (p) {
                var params = {
                    url: location.href
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/user/GetSinature/v1",
                    type: "get",
                    data: {
                        url: params.url
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 立即推广
             */
            spread: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    goodsId: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/goods/Spread/v1?userid=" + params.userid + '&goodsId=' + params.goodsId,
                    type: "post",
                    data: {
                        userid: params.userid,
                        goodsId: params.goodsId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 修改库存
             */
            updateStock: function (p) {
                var params = {
                    goodsId: "",
                    stock: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/goods/modifyStock",
                    type: "get",
                    data: {
                        "goodsItem.id": params.goodsId,
                        stock: params.stock
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 代理更多
             */
            proxyMoreGoods: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    index: 0,
                    size: 5
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/goods/ProxyMoreGoods/v1",
                    type: "get",
                    data: {
                        userid: params.userid,
                        index: params.index,
                        size: params.size
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 立即代理
             */
            proxyGoods: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    goodsId: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/goods/ProxyGood/v1?userid=" + params.userid + '&goodsId=' + params.goodsId,
                    type: "post",
                    data: {
                        userid: params.userid,
                        goodsId: params.goodsId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 代理商品详情
             */
            proxyGoodsDetail: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    goodsId: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/goods/ProxyGoodDetail/v1",
                    type: "get",
                    data: {
                        userid: params.userid,
                        goodsId: params.goodsId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 卖家获取商品详情
             */
            salerGoodsDetail: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    goodsId: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/goods/SalerGoodDetail/v1",
                    type: "get",
                    data: {
                        userid: params.userid,
                        goodsId: params.goodsId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 发布商品
             */
            putNewGoods: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    cid: '',
                    content: '',
                    topPrice: '',
                    botPrice: '',
                    proxy: '',
                    charges: '',
                    stock: '',
                    good_img: '',
                    postage: ''
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                var good = {
                    userid: params.userid,
                    cid: params.cid,
                    content: params.content,
                    topPrice: params.topPrice,
                    botPrice: params.botPrice,
                    proxy: params.proxy,
                    charges: params.charges,
                    stock: params.stock,
                    good_img: params.good_img,
                    postage: params.postage
                };
                $.ajax({
                    url: Model._URL_P + "/xt/api/goods/PutNewGoods/v1",
                    type: "post",
                    data: JSON.stringify(good),
                    contentType: 'application/json',
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 重新上架
             */
            modifyGoodsItemState: function (p) {
                var params = {
                    goodsId: sessionStorage.getItem("xt_userid"),
                    state: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/goods/modifyGoodsItemState",
                    type: "get",
                    data: {
                        "goodsItem.id": params.goodsId,
                        state: params.state
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 我的所有商品
             */
            findMyAllGoods: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/goods/findMyAllGoods",
                    type: "get",
                    data: {
                        "goodsItem.userid": params.userid,
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
        },


        /**
         * 发布需求模块
         */
        wannas: {
            /**
             * 获取我想要的商品
             */
            findAllWannasItem: function (p) {
                var params = {
                    pageSize: 0,
                    page: 0
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/wannas/findAllWannasItem",
                    type: "get",
                    data: {
                        pageSize: params.pageSize,
                        page: params.page
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                        me.resetload();
                    }
                });
                return Model._RESULT;
            }
            ,
            uploadsWannas: {
                do: function (formData) {
                    $.ajax({
                        url: Model._URL_P + '/wannas/addNewWannasItem',
                        type: 'post',
                        data: formData,
                        async: false,
                        cache: false,
                        contentType: false,
                        processData: false,
                        success: function (result) {
                            Model._RESULT = result;
                        },
                        error: function () {
                            Model._RESULT = Common.pa._AJAX_JSON_ERR;
                        }
                    });
                    return Model._RESULT;
                }
            }
        }
        ,
        /**
         * 店铺模块
         */
        business: {
            /**
             * 关注、取关店铺
             */
            attendBusiness: function (p) {
                var params = {
                    a_userid: sessionStorage.getItem("xt_userid"),
                    t_userid: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/attention/addNewAttentionorUpdateState",
                    type: "post",
                    data: {
                        "attention.a_userid": params.a_userid,
                        "attention.t_userid": params.t_userid
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 店铺详情
             */
            businessDetail: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    businessId: "",
                    index: 0,
                    size: 5
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/business/BussinessDetail/v1",
                    type: "get",
                    data: {
                        businessId: params.businessId,
                        userid: params.userid,
                        index: params.index,
                        size: params.size
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 店铺搜索
             */
            searchBusiness: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    condition: "",
                    index: 0,
                    size: 5
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/business/SearchBusiness/v1",
                    type: "get",
                    data: {
                        condition: params.condition,
                        userid: params.userid,
                        index: params.index,
                        size: params.size
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
        }
        ,
        /**
         * 订单模块
         */
        order: {
            /**
             * 创建订单（缴纳10元）
             */
            createOrder: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    goodsId: "",
                    proxyId: 0
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/order/TenPrice/v1?userid=" + params.userid + '&goodsId=' + params.goodsId + '&proxyId=' + params.proxyId,
                    type: "post",
                    data: {
                        userid: params.userid,
                        goodsId: params.goodsId,
                        proxyId: params.proxyId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,

            findAllOrder: function (p) {
                $.ajax({
                    url: Model._URL_P + "/order/findAllOrder",
                    type: "get",
                    data: {},
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;


            },
            /**
             * 出价
             */
            offerPrice: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    goodsId: "",
                    proxyId: "",
                    price: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/order/OfferPrice/v1?userid=" + params.userid + '&goodsId=' + params.goodsId + '&proxyId=' + params.proxyId + '&price=' + params.price,
                    type: "post",
                    data: {
                        userid: params.userid,
                        goodsId: params.goodsId,
                        proxyId: params.proxyId,
                        price: params.price
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 更新订单
             */
            orderDetail: function (p) {
                var params = {
                    state: "",
                    id: "",
                    userid: sessionStorage.getItem("xt_userid"),
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/order/UpdateOrderState",
                    type: "get",
                    data: {
                        "orderItem.id": params.id,
                        state: params.state,
                        "user.userid": params.userid
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 单个订单操作
             */
            perUpdateOrder: function (p) {
                var params = {
                    state: "",
                    id: "",
                    goodsid: "",
                    userid: sessionStorage.getItem("xt_userid"),
                    expressnumber: ''
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/order/UpdateOrderState",
                    type: "get",
                    data: {
                        "orderItem.id": params.id,
                        goodsid: params.state,
                        "user.userid": params.userid,
                        state: params.state,
                        expressnumber: params.expressnumber
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 查询订单详情
             */
            findAllMyOrderByOMID: function (p) {
                var params = {
                    id: "",
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/order/findAllMyOrderByOMID",
                    type: "get",
                    data: {
                        "orderMessage.id": params.id,
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 更新订单信息
             */
            updateOrder: function (p) {
                var params = {
                    state: "",
                    id: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/order/UpdateOrderState",
                    type: "post",
                    data: {
                        "orderItem.id": params.id,
                        state: params.state
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 申请退款
             */
            refundApply: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    orderId: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/order/RefundApply/v1?userid=" + params.userid + '&orderId=' + params.orderId,
                    type: "post",
                    data: {
                        userid: params.userid,
                        orderId: params.orderId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 撤销退款
             */
            revokeRefund: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    orderId: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/order/RevokeRefund/v1?userid=" + params.userid + '&orderId=' + params.orderId,
                    type: "post",
                    data: {
                        userid: params.userid,
                        orderId: params.orderId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 同意/拒绝退款
             */
            refundOperate: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    orderId: "",
                    type: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/order/RefundOperate/v1?userid=" + params.userid + '&orderId=' + params.orderId + '&type=' + params.type,
                    type: "post",
                    data: {
                        userid: params.userid,
                        orderId: params.orderId,
                        type: params.type
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 卖家发货
             */
            sendGoods: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    orderId: "",
                    express: "",
                    expressOrder: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/order/SendGoods/v1?userid=" + params.userid + '&orderId=' + params.orderId + '&express=' + params.express + '&expressOrder=' + params.expressOrder,
                    type: "post",
                    data: {
                        userid: params.userid,
                        orderId: params.orderId,
                        express: params.express,
                        expressOrder: params.expressOrder
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 买家确认收货
             */
            confirmReceipt: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    orderId: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/order/ConfirmReceipt/v1?userid=" + params.userid + '&orderId=' + params.orderId,
                    type: "post",
                    data: {
                        userid: params.userid,
                        orderId: params.orderId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 买家订单列表
             */
            buyerOrder: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    state: "",
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/order/findAllMyOrderByState",
                    type: "get",
                    data: {
                        "user.userid": params.userid,
                        state: params.state
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 卖家订单列表
             */
            findMyOrderByState: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    state: "",
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/order/findMyOrderByState",
                    type: "get",
                    data: {
                        "user.userid": params.userid,
                        state: params.state
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
        }
        ,
        /**
         * 消息模块
         */
        message: {
            /**
             * 消息列表
             */
            messageList: function (p) {
                var params = {
                    s_userid: sessionStorage.getItem("xt_userid"),
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/chat/findMyMessageList",
                    type: "get",
                    data: {
                        s_userid: params.s_userid,
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 消息详情
             */
            messageDetail: function (p) {
                var params = {
                    s_userid: sessionStorage.getItem("xt_userid"),
                    r_userid: ''
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/chat/findAllMyChatItem",
                    type: "get",
                    data: {
                        s_userid: params.s_userid,
                        r_userid: params.r_userid
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 发送消息
             */
            putMessage: function (p) {
                var params = {
                    s_userid: sessionStorage.getItem("xt_userid"),
                    r_userid: "",
                    content: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/chat/addNewChatItem",
                    type: "post",
                    data: {
                        "chatItem.s_userid": params.s_userid,
                        "chatItem.r_userid": params.r_userid,
                        "chatItem.content": params.content
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },

            //查询创建聊天的用户
            findAllChat: function () {
                $.ajax({
                    url: Model._URL_P + "/chat/findAllChat",
                    type: "post",
                    data: {},
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            },
            //删除其中一条消息
            deleteMessage: function (p) {
                var params = {
                    id: '',
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/chat/removeChatItem",
                    type: "post",
                    data: {
                        "chatItem.id": params.id,
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }


        }
        ,
        /**
         * 代言模块
         */
        represent: {
            /**
             * 获取代言首页
             */
            getRepresentInfo: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid")
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/represent/GetRepresentInfo/v1",
                    type: "get",
                    data: {
                        userid: params.userid
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 终止代言
             */
            cancelRepresent: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    businessId: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/represent/CancelRepresent/v1?userid=" + params.userid + '&businessId=' + params.businessId,
                    type: "post",
                    data: {
                        userid: params.userid,
                        businessId: params.businessId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 店铺代言列表
             */
            representList: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    index: 0,
                    size: 5
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/represent/RepresentList/v1",
                    type: "get",
                    data: {
                        userid: params.userid,
                        index: params.index,
                        size: params.size
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 选择代言
             */
            chooseRepresent: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    businessId: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/represent/ChooseRepresent/v1?userid=" + params.userid + '&businessId=' + params.businessId,
                    type: "post",
                    data: {
                        userid: params.userid,
                        businessId: params.businessId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 代言信息
             */
            representDetail: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid")
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/represent/RepresentDetail/v1",
                    type: "get",
                    data: {
                        userid: params.userid
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 添加/修改代言信息
             */
            modifyRepresent: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    price: "",
                    balance: ""
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/represent/ModifyRepresent/v1?userid=" + params.userid + '&price=' + params.price + '&balance=' + params.balance,
                    type: "post",
                    data: {
                        userid: params.userid,
                        price: params.price,
                        balance: params.balance
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 获取海报
             */
            myRepresent: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid")
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/represent/MyRepresent/v1?userid=" + params.userid,
                    type: "post",
                    data: {
                        userid: params.userid
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
            /**
             * 扫码关注
             */
            attentionByCode: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    userRepresentId: ''
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/xt/api/represent/AttentionByCode/v1?userid=" + params.userid + '&userRepresentId=' + params.userRepresentId,
                    type: "post",
                    data: {
                        userid: params.userid,
                        userRepresentId: params.userRepresentId
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
        }
        ,

//购物车
        shopcart: {
            /*
            添加到购物车
             */
            addNewShopcartItem: function (p) {
                var params = {
                    userid: '',
                    goodsid: '',
                    num: 0
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/shopcart/addNewShopcartItem",
                    type: "post",
                    data: {
                        "shopcartItem.userid": sessionStorage.getItem("xt_userid"),
                        "shopcartItem.c.goodsid": params.goodsid,
                        "shopcartItem.c.num": params.num
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                        // me.resetload();
                    }
                });
                return Model._RESULT;

            }
            ,
            /*

            查询购物车信息

             */
            findAllShopcartItemByUserid: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    pageSize: 0,
                    page: 0
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/shopcart/findAllShopcartItemByUserid",
                    type: "get",
                    data: {
                        "user.userid": params.userid,
                        pageSize: params.pageSize,
                        page: params.page
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;

            }
            ,
            /*

            结算购物车

             */
            addNewOrderByShopCart: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    goodsids: '',
                    counts: ''
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/order/addNewOrderByShopCart",
                    type: "get",
                    data: {
                        "user.userid": sessionStorage.getItem("xt_userid"),
                        goodsids: params.goodsids,
                        counts: params.counts
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;

            },
            /*

            删除购物车
             */
            deleteCartGood: function (p) {
                var params = {
                    userid: sessionStorage.getItem("xt_userid"),
                    id: '',
                };
                for (var i in p) {
                    params[i] = p[i];
                }
                $.ajax({
                    url: Model._URL_P + "/shopcart/removeShopcartItem",
                    type: "get",
                    data: {
                        "user.userid": sessionStorage.getItem("xt_userid"),
                        "goodsItem.id": params.id,
                    },
                    dataType: "json",
                    async: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;

            },


        }
        ,


// 工具模块
        util: {
            uploadsImg: function (formData) {
                var loading = weui.loading('loading', {
                    className: 'custom-classname'
                });
                var res = null;
                $.ajax({
                    url: Model._URL_P + "/Admin/User/AddImage",
                    type: 'post',
                    data: formData,
                    processData: false,
                    contentType: false,
                    cache: false,
                    async: false,
                    beforeSend: function () {
                        console.log("正在进行，请稍候");
                    },
                    dataType: 'JSON',
                    async: false,
                    timeout: 10000,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
            ,
        }
        ,
// 微信端
// wechat: {
//     /**
//      * 微信分享到朋友圈
//      */
//     weShare: function (gid, info, img) {
//         // 获取签名信息
//         var nonceStr = null,
//             signature = null,
//             timestamp = null;
//         var result = Model.goods.getShareInfo();
//         nonceStr = result.noncestr;
//         signature = result.sign;
//         timestamp = result.timespan;
//         wx.config({
//             debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
//             appId: 'wx16a0cab8942b16c2', // 必填，公众号的唯一标识
//             timestamp: timestamp, // 必填，生成签名的时间戳
//             nonceStr: nonceStr, // 必填，生成签名的随机串
//             signature: signature, // 必填，签名，见附录1
//             jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
//         });
//         var shareInfo = '打开眼界，进入文玩人的圈子！' + info;
//         wx.ready(function () {
//             wx.onMenuShareTimeline({
//                 title: shareInfo, // 分享标题
//                 link: 'http://www.hongmuwenwan.com/web/views/goods_detail.html?gid=' + gid, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
//                 imgUrl: img, // 分享图标
//                 success: function success() {
//                     var result = Model.user.share({
//                         goodsId: gid
//                     });
//                     weui.toast('分享成功，感谢您的分享');
//                     setTimeout(function () {
//                         location.reload();
//                     }, 1000);
//                 },
//                 cancel: function cancel() {
//                     // 用户取消分享后执行的回调函数
//                     weui.toast('分享已取消');
//                 },
//                 fail: function fail(_fail) {
//                     weui.toast('分享失败，请重新尝试。');
//                 }
//             });
//             wx.onMenuShareAppMessage({
//                 title: shareInfo, // 分享标题
//                 // desc: shareInfo,
//                 link: 'http://www.hongmuwenwan.com/web/views/goods_detail.html?gid=' + gid, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
//                 imgUrl: img, // 分享图标
//                 success: function success() {
//                     var result = Model.user.share({
//                         goodsId: gid
//                     });
//                     weui.toast('分享成功，感谢您的分享');
//                     setTimeout(function () {
//                         location.reload();
//                     }, 1000);
//                 },
//                 cancel: function cancel() {
//                     // 用户取消分享后执行的回调函数
//                     weui.toast('分享已取消');
//                 },
//                 fail: function fail(_fail) {
//                     weui.toast('分享失败，请重新尝试。');
//                 }
//             });
//         });
//     },
//     /**
//      * 图片上传
//      */
//     weImage: function () {
//         // 获取签名信息
//         var nonceStr = null,
//             signature = null,
//             timestamp = null;
//         var result = Model.goods.getShareInfo();
//         nonceStr = result.noncestr;
//         signature = result.sign;
//         timestamp = result.timespan;
//         wx.config({
//             debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
//             appId: 'wx16a0cab8942b16c2', // 必填，公众号的唯一标识
//             timestamp: timestamp, // 必填，生成签名的时间戳
//             nonceStr: nonceStr, // 必填，生成签名的随机串
//             signature: signature, // 必填，签名，见附录1
//             jsApiList: ['chooseImage', 'uploadImage', 'downloadImage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
//         });123456

//     }
// },
// 上传模块
        uploadsGoods: {
            do: function (formData) {
                $.ajax({
                    url: Model._URL_P + '/goods/addNewGoodsItem',
                    type: 'post',
                    data: formData,
                    async: false,
                    cache: false,
                    contentType: false,
                    processData: false,
                    success: function (result) {
                        Model._RESULT = result;
                    },
                    error: function () {
                        Model._RESULT = Common.pa._AJAX_JSON_ERR;
                    }
                });
                return Model._RESULT;
            }
        }
    }
;

